﻿package net.wangit.context;

import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.wangit.framework.session.UnitDataHelper;


/**
 * 本地线程上下文工具类，创建LocalContext
 * @author watson
 *
 */
public class LocalContextFactory {

	public LocalContextFactory() {
	}

	public static LocalContext createLocalContext(HttpServletRequest request,
			HttpServletResponse response, ServletConfig servletConfig) {
		LocalContext lc = new LocalContext();
		lc.setHttpServletRequest(request);
		lc.setHttpServletResponse(response);
		lc.setServletConfig(servletConfig);
		ActionContext ac = ActionContextFactory.createActionContext(request,
				servletConfig.getServletContext());
		UnitDataHelper.setMemoryData(ac);
		lc.setActionContext(ac);
		return lc;
	}
}
